package gui;

import javax.swing.ImageIcon;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JPanel;
//import javax.swing.UIManager;
//import javax.swing.UnsupportedLookAndFeelException;

public class MainMenu {
	public static void main(String[] args) {
		/*try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (ClassNotFoundException | InstantiationException
				| IllegalAccessException | UnsupportedLookAndFeelException e) {
			e.printStackTrace();
		}*/
		
		new GuiTemplate(getMainPanel());  // *****
	}
	
	
	public static JPanel getMainPanel()
	{
		final JPanel p1=new JPanel();
		
		p1.setSize(700,488);
		
		JButton btnCreatedataset = new JButton("Create data set");
		btnCreatedataset.setIcon(new ImageIcon(MainMenu.class.getResource("/images/newDS.png")));
		btnCreatedataset.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				p1.removeAll();		        
		        p1.add(CreateDS.CreateDsPanel());
		        p1.validate();
		        p1.repaint();
			}
		});
		
		JButton btnRunCRST = new JButton("Run CRST");
		btnRunCRST.setIcon(new ImageIcon(MainMenu.class.getResource("/images/binary-tree.png")));
		btnRunCRST.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				p1.removeAll();
		        p1.add(RunCrst.RunCrstPanel());
		        p1.validate();
		        p1.repaint();
			}
		});
		

		
		GroupLayout gl_p1 = new GroupLayout(p1);
		gl_p1.setHorizontalGroup(
			gl_p1.createParallelGroup(Alignment.LEADING)
				.addGroup(Alignment.TRAILING, gl_p1.createSequentialGroup()
					.addGap(266)
					.addGroup(gl_p1.createParallelGroup(Alignment.TRAILING)
						.addComponent(btnRunCRST, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
						.addComponent(btnCreatedataset, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE))
					.addGap(266))
		);
		gl_p1.setVerticalGroup(
			gl_p1.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_p1.createSequentialGroup()
					.addGap(27)
					.addComponent(btnCreatedataset, GroupLayout.PREFERRED_SIZE, 82, GroupLayout.PREFERRED_SIZE)
					.addGap(71)
					.addComponent(btnRunCRST, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(235, Short.MAX_VALUE))
		);
		gl_p1.setAutoCreateContainerGaps(true);
		gl_p1.setAutoCreateGaps(true);
		p1.setLayout(gl_p1);
		
		return p1;
	}
	
}
